<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:pe="http://primefaces.org/ui/extensions">


    <ui:define name="content">

        <h:panelGroup >
            <h:form id="form"  >
                <p:panel id="panIx"  >
                    <f:facet name="header" >
                        <h:outputLabel value="List of Service"></h:outputLabel>
                    </f:facet>

                    <h:panelGrid columns="2" styleClass="alignTop" >
                        <p:panel >
                            <p:dataTable  value="#{itemController.allItems}" 
                                          var="i"   
                                          rowKey="#{i.id}" 
                                          selection="#{itemController.selectedList}" 
                                          rowIndexVar="s"
                                          rows="20"
                                          paginator="true"
                                          paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                          rowsPerPageTemplate="20,50,100,500,1000,1500"
                                          >

                                <p:column  selectionMode="multiple" style="width: 10px;">                            
                                </p:column>

                                <p:column >
                                    <f:facet name="header">
                                        <h:outputLabel value="No" />
                                    </f:facet>
                                    <h:outputLabel value="#{s+1}" />
                                </p:column>

                                <p:column   sortBy="#{i.name}"
                                            filterMatchMode="contains" filterBy="#{i.name}" >  
                                    <f:facet name="header">
                                        <h:outputLabel value="Item Name" />
                                    </f:facet>
                                    <h:outputLabel value="#{i.name}"/>
                                </p:column>

                                <p:column sortBy="#{i.institution.name}"
                                          filterMatchMode="contains" filterBy="#{i.institution.name}">
                                    <f:facet name="header">
                                        <h:outputLabel value="Institution" />
                                    </f:facet>
                                    <h:outputLabel value="#{i.institution.name}" ></h:outputLabel>
                                </p:column>

                                <p:column sortBy="#{i.department.name}"
                                          filterMatchMode="contains" filterBy="#{i.department.name}">
                                    <f:facet name="header">
                                        <h:outputLabel value="Department" />
                                    </f:facet>
                                    <h:outputLabel value="#{i.department.name}" ></h:outputLabel>
                                </p:column>

                            </p:dataTable>
                        </p:panel>
                        <h:panelGrid columns="1" >
                            <p:panel >
                                <p:commandButton ajax="false" value="List All Items" action="#{itemController.createMasterItemsList()}" styleClass="noPrintButton" >
                                </p:commandButton>
                            </p:panel>
                            <p:panel >
                                <p:commandButton ajax="false" value="List All Master Items" action="#{itemController.createAllItemsList()}" styleClass="noPrintButton" >
                                </p:commandButton>
                            </p:panel>
                            <p:panel >
                                <p:commandButton ajax="false" value="Make Selected Items as Master Items" action="#{itemController.makeSelectedAsMasterItems()}" styleClass="noPrintButton" >
                                </p:commandButton>
                            </p:panel>
                            <p:panel >
                                <h:panelGrid columns="2" >
                                    <h:outputLabel value="Institution" ></h:outputLabel>
                                    <p:selectOneMenu id="cmbIns" value="#{itemController.instituion}" >
                                        <f:selectItem itemLabel="Select Institution" ></f:selectItem>
                                        <f:selectItems value="#{institutionController.companies}" var="i"
                                                       itemLabel="#{i.name}" itemValue="#{i}" ></f:selectItems>
                                        <f:ajax execute="@this" render="cmbDept" ></f:ajax>
                                    </p:selectOneMenu>
                                    <h:outputLabel value="Department" ></h:outputLabel>
                                    <p:selectOneMenu id="cmbDept" value="#{itemController.department}" >
                                        <f:selectItem itemLabel="Select Department" ></f:selectItem>
                                        <f:selectItems value="#{itemController.departments}" 
                                                       var="d"
                                                       itemLabel="#{d.name}" itemValue="#{d}" ></f:selectItems>
                                    </p:selectOneMenu>
                                </h:panelGrid>
                                <p:commandButton value="Create New Items for Selected Master Items"
                                                 action="#{itemController.createNewItemsFromMasterItems}" ajax="false" ></p:commandButton>

                                <p:commandButton value="Update Items"
                                                 action="#{itemController.updateItemsFromMasterItems}" ajax="false" ></p:commandButton>
                            </p:panel>

                        </h:panelGrid>



                    </h:panelGrid>

                </p:panel>
            </h:form>

        </h:panelGroup>

    </ui:define>

</ui:composition>




